/********************************************************************
  Mega Mario SRC
    created:	2005/09/18
	created:	18:9:2005   10:13
	author:		Jens Wellmann (c)
*********************************************************************/


#include "goomba.h"
#include "functions.h"
#include "MessageBus.h"

SDL_Surface * cGoomba::GOOMBA_SURFACE[3] = {NULL};

cGoomba::cGoomba(int x,int y) : cEnemy(x,y)
{
	W = GOOMBA_SURFACE[0]->w;
	H = GOOMBA_SURFACE[0]->h;
	scoring = 100;
}

void cGoomba::initGOOMBA()
{
	GOOMBA_SURFACE[0] = LoadIMG(DATADIR "gfx/characters/goomba1.png");
	GOOMBA_SURFACE[1] = LoadIMG(DATADIR "gfx/characters/goomba2.png");
	GOOMBA_SURFACE[2] = LoadIMG(DATADIR "gfx/characters/goomba3.png");
}

void cGoomba::headbang()
{
	DEATHcount++;
	PLAYER->y_speed = -10;
	PLAYSOUND1(S_STOMP);
	MessageBus::get_MsgBusInstance()->sendMessageFunc<void, int, int, int, const char *> (x, y, scoring, "InitScore");
	BLOOD_GENERATOR->newBlood(x,y);
    this->dying = 1;
}

void cGoomba::draw()
{
	if(DEATHcount)
		SDL_UpperBlit(GOOMBA_SURFACE[2],0,screen,&rect);
	else 
		SDL_UpperBlit(GOOMBA_SURFACE[walkcount],0,screen,&rect);
}

void cGoomba::move(float dt, cPlayer* mario)
{
	this->update();
    if (!this->dying && !this->dead){
       if ((playerTouchLeft(mario) + playerTouchRight(mario))) {
		   if (!mario->stat){
              mario->die();
           }
		   else{
              mario->changeStat(0);
           }
	   }
    }
}

void cGoomba::collisionWithOthers(NpcItem* sprite)
{

}